package com.infnoon.rpc.protocol;

//import org.junit.Assert;
//import org.junit.Test;


public class ProtocolMessageTest {

//    @Test
//    public void testEncodeAndDecode() throws IOException {
//        // 构造消息
//        ProtocolMessage<RpcRequest> protocolMessage = new ProtocolMessage<>();
//        ProtocolMessage.Header header = new ProtocolMessage.Header();
//        header.setMagic(ProtocolConstant.PROTOCOL_MAGIC);
//        header.setVersion(ProtocolConstant.PROTOCOL_VERSION);
//        header.setSerializer((byte) ProtocolMessageSerializerEnum.JDK.getKey());
//        header.setType((byte) ProtocolMessageTypeEnum.REQUEST.getKey());
//        header.setStatus((byte) ProtocolMessageStatusEnum.OK.getValue());
//        header.setRequestId(IdUtil.getSnowflakeNextId());
//        header.setBodyLength(0);
//        RpcRequest rpcRequest = new RpcRequest();
//        rpcRequest.setServiceName("myService");
//        rpcRequest.setMethodName("myMethod");
//        rpcRequest.setServiceVersion(RpcConstant.DEFAULT_SERVICE_VERSION);
//        rpcRequest.setParameterTypes(new Class[]{String.class});
//        rpcRequest.setArgs(new Object[]{"aaa", "bbb"});
//        protocolMessage.setHeader(header);
//        protocolMessage.setBody(rpcRequest);
//
//        Buffer encodeBuffer = ProtocolMessageEncoder.encode(protocolMessage);
//        ProtocolMessage<?> message = ProtocolMessageDecoder.decode(encodeBuffer);
//        Assert.assertNotNull(message);
//    }

}

